<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>框分类信息系统 后台管理</title>
    <script type="text/javascript" language="javascript" src="__PUBLIC__/Admin/js/addadvert.js"></script>
    <link href="__PUBLIC__/Admin/css/addadvert.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript" src="__PUBLIC__/Admin/js/jquery-1.8.3.min.js"></script>
    <style>
            table th {
            background-color: #11B6B6;
            color: white;
            font-family: "微软雅黑";
        }
        
        th {
            font-weight: bold;
        }
        
        td,
        th {
            display: table-cell;
            vertical-align: inherit;
        }
        
        table {
            display: table;
            border-collapse: separate;
            border-spacing: 2px;
            border-color: grey;
        }
        
        table {
            width: 100%;
            text-align: center;
            margin-left: auto;
            margin-right: auto;
        }
        
        table th {
            background-color: #11B6B6;
            color: white;
            font-family: "微软雅黑";
    </style>
    <div class="top" id="top">
        <style>
            table th {
                background-color: #11B6B6;
                color: white;
                font-family: "微软雅黑";
            }
        </style>
</head>

<body>
    <div class="right-nav" id='right-nav'>
        <ul>
            <li style="float:left;"><img src="__PUBLIC__/Admin/images/home.png"></li>
            <li style="float:left; margin-left:25px;">您当前的位置：</li>
            <li><a href="__MODULE__/Index/index">后台首页</a></li>
            <li>></li>
            <li><a href="__SELF__">广告投放管理</a></li>
        </ul>
    </div>
    <div align="center">
        <div class="main" align="left">

            <script type="text/javascript" language="javascript" src="./m.js"></script>
            <script type="text/javascript" language="javascript" src="./jquery-1.8.0.js"></script>
            <div class="top" id="top">
            </div>
            <script type="text/javascript">
                var objNav = [{
                    mUrl: "/index.aspx",
                    sNavName: ["网站设置", "导航设置", "快速导航设置", "安全设置", "上传设置", "邮箱设置", "友情链接", "内页链接", "广告设置", "管理员设置"],
                    sNavUrl: ["/config.aspx", "/nav.aspx", "/nav1.aspx", "/regex.aspx", "/uploadConfig.aspx", "/email.aspx", "/link.aspx", "/link1.aspx", "/guanggao.aspx", "/admin.aspx"]
                }, {
                    mUrl: "/config.aspx",
                    sNavName: ["网站设置", "导航设置", "快速导航设置", "安全设置", "上传设置", "邮箱设置", "友情链接", "内页链接", "广告设置", "管理员设置"],
                    sNavUrl: ["/config.aspx", "/nav.aspx", "/nav1.aspx", "/regex.aspx", "/uploadConfig.aspx", "/email.aspx", "/link.aspx", "/link1.aspx", "/guanggao.aspx", "/admin.aspx"]
                }, {
                    mUrl: "/xxgl.aspx",
                    sNavName: ["信息管理", "发布信息"],
                    sNavUrl: ["/xxgl.aspx", "/post.aspx"]
                }, {
                    mUrl: "/news.aspx",
                    sNavName: ["文章管理", "发布文章", "文章分类"],
                    sNavUrl: ["/news.aspx", "/newsPost.aspx", "/newsSort.aspx"]
                }, {
                    mUrl: "/plgl.aspx",
                    sNavName: ["信息评论", "商家评论", "商家留言", "文章评论"],
                    sNavUrl: ["/plgl.aspx", "/biz/review.aspx", "/biz/bizMessage.aspx", "/newspl.aspx"]
                }, {
                    mUrl: "/sort.aspx",
                    sNavName: ["信息分类", "商家分类", "地区分类", "文章分类"],
                    sNavUrl: ["/sort.aspx", "/bizsort.aspx", "/city.aspx", "/newsSort.aspx"]
                }, {
                    mUrl: "/token.aspx",
                    sNavName: ["接口设置", "回复管理", "添加回复", "菜单管理", "微信商家会员"],
                    sNavUrl: ["/weixin/token.aspx", "/weixin/weixin.aspx", "/weixin/weixinAdd.aspx", "/weixin/weixinMenu.aspx", "/weixin/weixinMember.aspx"]
                }];
                var sMPath = "/guanggao.aspx";
                var sSPath = "/guanggao.aspx";
                var sAdminPath = "admin";
                if (sMPath != "") {
                    q$("nav1").innerHTML = "";
                    for (i = 0; i < objNav.length; i++) {
                        if (objNav[i].mUrl.indexOf(sMPath) != -1) {
                            var sNavStr = "";
                            for (t = 0; t < objNav[i].sNavUrl.length; t++) {
                                sNavStr += "<li><a href=\"/" + sAdminPath + objNav[i].sNavUrl[t] + "\">" + objNav[i].sNavName[t] + "</a></li>";
                            }
                            q$("nav1").innerHTML = sNavStr;
                        }
                        for (t = 0; t < objNav[i].sNavUrl.length; t++) {
                            if (objNav[i].sNavUrl[t].indexOf(sMPath) != -1) {
                                sMPath = objNav[i].mUrl;
                                var sNavStr1 = "";
                                for (t = 0; t < objNav[i].sNavUrl.length; t++) {
                                    sNavStr1 += "<li><a href=\"/" + sAdminPath + objNav[i].sNavUrl[t] + "\">" + objNav[i].sNavName[t] + "</a></li>";
                                }
                                q$("nav1").innerHTML = sNavStr1;
                            }
                        }
                    }
                }

                var sAtag = q$("nav").getElementsByTagName("a");
                for (i = 0; i < sAtag.length; i++) {
                    if (sAtag[i].href.indexOf(sMPath) != -1) {
                        sAtag[i].className = "sto";
                        getElementPos(sAtag[i]).x;
                    }
                }
                sAtag = q$("nav1").getElementsByTagName("a");
                for (i = 0; i < sAtag.length; i++) {
                    if (sAtag[i].href.indexOf(sSPath) != -1) {
                        sAtag[i].className = "sto";
                    }
                }
            </script>
            <div class="d01">
                <div align="center">
                    <form action="__CONTROLLER__/index" name="guanggao" method="get">
                        <strong>筛选：</strong>
                        <select name="ad_position" id="ad_position" id="">
                            <option value="">全部位置</option>
                            <option value="中上">中间横幅</option>
                            <option value="中下">格子展位</option>
                            <option value="左">左对联</option>
                            <option value="右">右对联</option>
                        </select>
                        &nbsp;&nbsp;&nbsp;
                        <!--暂时由于where 中的ambiguous问题不写了<select name="cat_id" id="" >
                                    <option value="">选择分类</option>
                                    <option value="2">中间横幅</option>
                                    <option value="3">格子展位</option>
                                    <option value="4">左对联</option>
                                    <option value="5">右对联</option>
                                </select>
                                &nbsp;&nbsp;&nbsp;-->


                        <select name="ad_overtime" id="ad_overtime" id="">
                            <option value="">全部日期</option>
                            <option value="1">未到期</option>
                            <option value="0">到期广告</option>
                        </select>
                        &nbsp;&nbsp;&nbsp;
                        <select name="is_effect" id="is_effect" id="">
                            <option  value="">显示状态</option>
                            <option  value="1">显示</option>
                            <option value="0">隐藏</option>
                        </select>
                        &nbsp;&nbsp;&nbsp;

                        <span>模糊搜索</span>
                        <input type="text" name='ad_name' id='ad_name' />
                        <input id='search' type="button" value="搜索" />
                        <!--<input type="radio" value="0" name="t" onclick="guanggao.submit()" />全部广告
                                <input type="radio" value="1" name="t" onclick="guanggao.submit()" /> 到期广告-->
                    </form>
                </div>
                <table width="985" border="0" id="table1" class="fTableNO" cellspacing="0" cellpadding="0">
                    <thead>
                        <tr>
                            <td colspan="9" class="head">
                            </td>
                        </tr>
                        <tr>
                            <th width="30" class="head">id</th>
                            <th width="40" class="head">排序</th>
                            <th width="70" class="head">缩略图</th>
                            <th width="178" class="head">广告位名称,位置</th>
                            <!--<th width="170" class="head">[宽/高] [上/右/下/左边距]</th>-->
                           <!-- <th width="170" class="head">所属分类</th>-->
                            <th width="108" class="head">开始日期</th>
                            <th width="108" class="head">到期日期</th>
                            <th width="30" class="head">显示</th>
                            <th width="160" class="head">
                                <div class="inputButtomCl"><a href="__CONTROLLER__/addAdvert">添加广告</a></div>
                            </th>

                        </tr>
                    </thead>
                    <tbody>
                        <foreach name="adverts" item="vo">
                            <tr class="bg01">
                                <td>{$vo.id}</td>
                                <td>{$vo.sort_order}</td>
                                <td><span class="xgpic">图片</span>
                                    <br />
                                </td>
                                <td><span class="price">{$vo.ad_name}</span><span class="price">{$vo.ad_position}</span></td>
                                <!--<td>{$vo.cat_name}</td>-->
                                <td>{$vo.ad_createtime}</td>
                                <td>{$vo.ad_overtime}</td>
                                <td><a href="javascript:;" class='changeshow'><strong class="xgpic"><image src=__PUBLIC__/Admin/images/{$vo.is_effect}.gif alt='点击修改'></image></strong></a></td>
 <td>
    <div class="bt1 fl5"><a href="__CONTROLLER__/edit/id/{$vo.id}" target="_self">修改</a></div>
    <div class="bt1 fl"><a href="__CONTROLLER__/del/id/{$vo.id}" onclick="Javascript:return confirm('     你真的要删除?')">删除</a></div>
    <if condition="($vo.ad_position eq '左') OR ($vo.ad_position eq '右') ">
        <a href="__CONTROLLER__/guDing/id/{$vo.id}" onclick="Javascript:return confirm('您确定将此广告设为固定显示吗?注意此操作会将所有其他对联显示在右侧')">将此设为左侧固定</a>
    </if>
<!--<switch name="vo.ad_position">
    <case value="左|右">设为固定显示</case>
</switch>-->

</td>
                            </tr>
                        </foreach>
                        
                        <tr id='pageTr' align='center'>
                            <td colspan="8">{$show}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript">
$("#table1").delegate('')
    //表格隔行换色
    $("tbody tr:nth-child(2n+1)").css({
        'background': 'rgb(204, 204, 204)'
    });
    //导航栏左浮动
    $("#right-nav ul li").css({
        'float': 'left',
        'listStyle': 'none'
    });
    //当点击上下页时,,用ajax获取数据
   $("tbody #pageTr a").each(function(){
       $(this).click(function(){
            var data='';
            var url=$(this)[0].href;
            ajaxGet(url,data);
            return false;  
       })

   }) ;
    //当点击搜索时,用ajax获取数据
    $("#search").click(function() {
        //获取get数据
        var url='/index.php/Admin/Advert/index'
        var data = {
            "ad_position": $('#ad_position').val(),
            "ad_overtime": $('#ad_overtime').val(),
            "is_effect": $('#is_effect').val(),
            "ad_name": $('#ad_name').val()
        };
        //console.log(data);
        //用jq的ajax方法
        ajaxGet(url,data);
        }                 
    );
    function ajaxGet(url,data){
        $.get(
            url, data,
            function(obj) {
                console.log(obj);
                var advert = obj.adverts;
                var show="<tr id='pageTr' align='center'><td colspan=9>"+obj.show+"</td></tr>";
                var str = "";
                for (var i = 0, len = advert.length; i < len; i++) {
                    str += "<tr class=bg01><td>" + advert[i].id + "</td><td>" +         advert[i].sort_order + "</td><td><span class=xgpic>图片</span><br /></td><td><span class=price>" + advert[i].ad_name + "</span><span class=price>" + advert[i].ad_position + "</span></td><td>" + advert[i].ad_createtime + "</td><td>" + advert[i].ad_overtime + "</td><td><a href='javascript:;'><strong class=xgpic><img src=__ROOT__/Public/Admin/images/"+advert[i].is_effect+".gif alt= /></strong></a></td><td><div class='bt1 fl5' ><a href=/index.php/Admin/Advert/edit/id/" + advert[i].id + "target=_self>修改</a></div><div class='bt1 fl'><a href='__CONTROLLER__/del/id/"+advert[i].id+"' onclick=\"return confirm('你真的要删除啦?')\">删除</a></div><a class=setVip mark="+advert[i].ad_position+" style='display:none;' href='__CONTROLLER__/guDing/id/"+advert[i].id+"' onclick=\"Javascript:return confirm('您确定将此广告设为固定显示吗?注意此操作会将所有其他对联显示在右侧')\">将此设为左侧固定</a></td></tr>";
                }
                $("#table1 tbody").html(str+show);
                $(".setVip").each(function(){
                    var _this=$(this);
                    console.log($(this).attr("mark"));
                    if(_this.attr("mark")=="左" || _this.attr("mark")=="右"){
                        _this.css({'display':'block'});
                    };
                });
                //重新指定样式,不明白为什么ajax后样式会消失?
                $("tbody tr:nth-child(2n+1)").css({
                    'background': 'rgb(204, 204, 204)'
                });
                $("tbody #pageTr a").each(function(){
                   $(this).click(function(){
                        var data='';
                        var url=$(this)[0].href;
                        ajaxGet(url,data);
                        return false;  
                   })

                });
                


            }, 'json'
        );
    }
</script>
</html>










































